Skip to content

fix: simplify quality gate workflow and harden monitor coverage#7

Merged
spazyCZ merged 5 commits intotestfrom
fix/quality-gate-permissions
Mar 9, 2026
Merged

fix: simplify quality gate workflow and harden monitor coverage#7
spazyCZ merged 5 commits intotestfrom
fix/quality-gate-permissions

Conversation

@spazyCZ
Copy link
Copy Markdown
Owner

@spazyCZ spazyCZ commented Mar 9, 2026

Summary

This PR does two things:

  • simplifies the Claude quality-gate workflow so agents provide comment-only feedback on main and test PRs
  • carries the stacked ptop3 runtime and test hardening changes needed for the monitor refactor and coverage expansion

Changes

  • add claude-quality-gate.yml with comment-only prompts for test, docs, and code review agents
  • refactor ptop3.monitor sampling/sorting/TUI state, including tree selection fixes and scroll handling
  • remove the non-functional net sort mode from the TUI/CLI
  • expand monitor and helper-script tests and add pytest coverage configuration
  • add a changelog entry for the removed net sort mode
  • make ProcessSampler use its own swap reader path instead of the global default sampler cache
  • replace the tests/conftest.py import-cache hack with explicit pytest pythonpath = ["."]

Verification

  • pytest
  • ruff check .

Reviewer follow-ups addressed

  • sampler swap-cache lookup now respects the active ProcessSampler instance
  • test import resolution now uses pytest configuration instead of clearing sys.modules
  • CHANGELOG.md documents the removal of net sort
  • PR title/body now reflect the full branch scope instead of only the workflow changes

spazyCZ and others added 2 commits March 9, 2026 13:59
- Remove auto-commit instructions from all three agents — contents: read
  prevents pushing commits on pull_request events
- Agents now post PR comments with proposed fixes/snippets instead
- Add test branch to workflow trigger (feature PRs target test, not main)

Fixes Copilot review comments on PR #5.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 9, 2026 13:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the repo’s automation and Python code/tests around ptop3, including a new Claude “quality gate” workflow and a substantial refactor/extension of the ptop3.monitor data/UI layer with expanded test coverage.

Changes:

  • Add a new claude-quality-gate.yml workflow configured for PR comment-only feedback and triggering on main/test.
  • Refactor ptop3/monitor.py (sampling/caching via ProcessSampler, sorting helpers, scrolling, net sort removal) and expand tests/test_monitor.py significantly.
  • Improve tests for privileged subscripts (swap_clean, drop_caches) and add packaging metadata/coverage configuration in pyproject.toml.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
.github/workflows/claude-quality-gate.yml Adds a PR-triggered “quality gate” workflow with three Claude agents and comment-only instructions.
ptop3/monitor.py Refactors process sampling/caching, removes net sorting, adds sort helpers + scrolling, and adjusts TUI behavior.
tests/test_monitor.py Adds extensive unit tests for monitor sampling, helpers, and TUI behavior (with mocked curses/psutil).
tests/test_swap_clean.py Adds more swap-clean edge case tests (short lines, swapoff failure, dry-run, file-by-file).
tests/test_drop_caches.py Adds a main() error-path test and minor test cleanup.
tests/test_sudo_config.py Minor import cleanup.
tests/conftest.py Adds sys.path/module-cache manipulation for test imports.
pyproject.toml Adds project.urls and coverage configuration sections.

Comment on lines +227 to +230
rss_mb = rss_bytes / (1024 * 1024)
cpu = 0.0 if lite and rss_mb < 2.0 else proc.cpu_percent()
swap_mb = _swap_value(proc.pid, rss_mb, lite)
io_read_mb, io_write_mb = _io_values(proc, rss_mb, lite)
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProcessSampler._sample_process() computes swap_mb via _swap_value(), which calls the module-level read_vmswap_mb() and therefore always uses DEFAULT_SAMPLER’s cache. This couples all ProcessSampler instances together and makes per-instance TTL/cache behavior ineffective. Consider moving _swap_value onto ProcessSampler (or passing self.read_vmswap_mb into the helper) so sampling uses the current sampler instance consistently.

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +13
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))

for module_name in list(sys.modules):
if module_name == "ptop3" or module_name.startswith("ptop3."):
sys.modules.pop(module_name, None)
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conftest mutates sys.path and forcefully removes all ptop3* entries from sys.modules at import time. In CI the package is already installed via pip install -e ".[dev]", so this is redundant and can mask real packaging/import issues or make tests behave differently from installed usage. Prefer removing this block and relying on the editable install (or configure PYTHONPATH/pytest pythonpath explicitly if needed).

Copilot uses AI. Check for mistakes.

SORT_KEYS = ("mem", "cpu", "rss", "swap", "io", "net", "count")

SORT_KEYS = ("mem", "cpu", "rss", "swap", "io", "count")
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SORT_KEYS (and the help text) drops the net sort option, which is a user-facing behavior change (keybinding s cycle and CLI --sort). CHANGELOG.md currently doesn’t mention this under ## [Unreleased]; please add an entry (likely under Changed or Removed) describing the removal so users aren’t surprised.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
name: Claude Quality Gate

on:
pull_request:
branches: [main, test]
types: [opened, synchronize, reopened]

permissions:
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description/title focuses on GitHub Actions quality-gate prompt tweaks, but this PR also includes substantial runtime and test changes (e.g., ptop3/monitor.py refactor, new coverage config, test updates). Please update the PR description (and/or split into separate PRs) so reviewers can clearly understand the scope and risk.

Copilot uses AI. Check for mistakes.
@spazyCZ spazyCZ changed the title fix: quality gate agents comment-only, add test branch trigger fix: simplify quality gate workflow and harden monitor coverage Mar 9, 2026
…issions

# Conflicts:
#	.github/workflows/claude-quality-gate.yml
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 89.48498% with 49 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
ptop3/monitor.py 89.48% 49 Missing ⚠️

📢 Thoughts on this report? Let us know!

@spazyCZ spazyCZ merged commit e095bb7 into test Mar 9, 2026
8 of 12 checks passed
spazyCZ added a commit that referenced this pull request Mar 10, 2026
* fix: simplify quality gate workflow and harden monitor coverage (#7)

* fix: harden monitor behavior and raise coverage

* fix: quality gate agents comment-only, add test branch trigger

- Remove auto-commit instructions from all three agents — contents: read
  prevents pushing commits on pull_request events
- Agents now post PR comments with proposed fixes/snippets instead
- Add test branch to workflow trigger (feature PRs target test, not main)

Fixes Copilot review comments on PR #5.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address PR review feedback

* fix: simplify claude code review workflow

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: simplify Claude workflows and TestPyPI publishing (#8)

* fix: harden monitor behavior and raise coverage

* fix: quality gate agents comment-only, add test branch trigger

- Remove auto-commit instructions from all three agents — contents: read
  prevents pushing commits on pull_request events
- Agents now post PR comments with proposed fixes/snippets instead
- Add test branch to workflow trigger (feature PRs target test, not main)

Fixes Copilot review comments on PR #5.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: address PR review feedback

* fix: simplify claude code review workflow

* ci: auto-version testpypi publishes

* ci: set testpypi environment

* chore: ignore coverage artifacts

* chore: use standard python gitignore

* test: tighten swap fallback assertion

* fix: pass github_token to claude-code-action to resolve permission denials

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants